package com.jisu.common;

import lombok.Data;

@Data
public class ResultVo<T>{

    private String reason; //本次业务操作响应消息
    private boolean flag;//本次业务操作响应状态 true/false
    private T result;

    //成功-返回结果集
    public static <T> ResultVo<T> success(String reason,T result){
        ResultVo<T> model=new ResultVo<>();
        model.setFlag(true);
        model.setReason(reason);
        model.setResult(result);
        return model;
    }
    //成功-无返回结果集
    public static  ResultVo success(String reason){
        ResultVo model=new ResultVo<>();
        model.setFlag(true);
        model.setReason(reason);
        return model;
    }
    //失败
    public static  ResultVo fail(String reason){
        ResultVo model=new ResultVo<>();
        model.setFlag(false);
        model.setReason(reason);
        return model;
    }

    public static <T> ResultVo fail(String reason,T result){
        ResultVo model=new ResultVo<>();
        model.setFlag(false);
        model.setReason(reason);
        model.setResult(result);
        return model;
    }

}

